#!/bin/bash
# Run ebizzy benchmark

###SHELLPACK preamble ebizzy-bench 0.3

EBIZZY_DURATION=30

###SHELLPACK parseargBegin
###SHELLPACK parseargInstall
###SHELLPACK parseargParam --max-threads       EBIZZY_MAX_THREADS
###SHELLPACK parseargParam --iterations        EBIZZY_ITERATIONS
###SHELLPACK parseargParam --duration          EBIZZY_DURATION
###SHELLPACK parseargEnd
###SHELLPACK monitor_hooks

###SHELLPACK check_install_required ebizzy-${VERSION}
###SHELLPACK init_complete

EXIT_CODE=$SHELLPACK_SUCCESS

set_mmtests_numactl $EBIZZY_MAX_THREADS $EBIZZY_MAX_THREADS

###SHELLPACK threads_large_stride_begin 1 $EBIZZY_MAX_THREADS
	monitor_pre_hook $LOGDIR_RESULTS $NR_THREADS
	###SHELLPACK iteration_begin $EBIZZY_ITERATIONS
		echo Iteration:$ITERATION Threads:$NR_THREADS/$EBIZZY_MAX_THREADS \
			| tee -a $LOGDIR_RESULTS/ebizzy-$NR_THREADS-$ITERATION.log

		save_rc $SHELLPACK_SOURCES/ebizzy-${VERSION}-installed/bin/ebizzy \
			-S $EBIZZY_DURATION \
			-t $NR_THREADS \
			| tee $LOGDIR_RESULTS/ebizzy-$NR_THREADS-$ITERATION.log
		recover_rc
		RETVAL=$?
		if [ $RETVAL -ne 0 ]; then
			error "ebizzy returned non-zero value with $NR_THREADS"
			EXIT_CODE=$SHELLPACK_ERROR
		fi
	###SHELLPACK iteration_end
	monitor_post_hook $LOGDIR_RESULTS $NR_THREADS
###SHELLPACK threads_stride_end

exit $EXIT_CODE
